<?php
/**
 * Created by JetBrains PhpStorm.
 * User: dvynograd
 * Date: 22.01.13
 * Time: 15:22
 * To change this template use File | Settings | File Templates.
 */

namespace Vozminoski\StoreBundle\DataFixtures\ORM;

use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\Persistence\ObjectManager;
use Vozminoski\StoreBundle\Entity\Catalog;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;


class LoadCatalogData extends AbstractFixture implements OrderedFixtureInterface
{
    /**
     * {@inheritDoc}
     */
    public function load(ObjectManager $manager)
    {
        $catalog = new Catalog();
        $catalog->setIsActive(true);
        $catalog->setName('Мужские');
        $catalog->setOrder(1);
        $catalog->setUrl('man');
        $manager->persist($catalog);
        $this->addReference('man-category', $catalog);

        $catalog = new Catalog();
        $catalog->setIsActive(true);
        $catalog->setName('Женские');
        $catalog->setUrl('women');
        $catalog->setOrder(2);
        $manager->persist($catalog);
        $this->addReference('women-category', $catalog);


        $catalog = new Catalog();
        $catalog->setIsActive(true);
        $catalog->setName('Детские');
        $catalog->setUrl('children');
        $catalog->setOrder(3);
        $manager->persist($catalog);
        $this->addReference('children-category', $catalog);

        $manager->persist($catalog);
        $manager->flush();
    }

    /**
     * {@inheritDoc}
     */
    public function getOrder()
    {
        return 1; // the order in which fixtures will be loaded
    }
}